package cn.wangliang181230.boot.web.properties;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Data
//@ConfigurationProperties("my.test")
public class MyTestProperties implements InitializingBean {

	private String ip;

	private String string;
	private Integer integer;
	private Long longValue;
	private Boolean bool;
	private String[] array;

	private Set<String> stringSet;
	private Set<Integer> integerSet;
	private List<String> stringList;
	private List<Integer> integerList;

	private Map<String, String> map;

	private InternalProperties internal;
	private InternalProperties[] internalArray;
	private Set<InternalProperties> internalSet;
	private List<InternalProperties> internalList;
	private Map<String, InternalProperties> internalMap;


	public MyTestProperties() {
		System.out.println("MyProperties: constructor");
	}


	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("MyProperties: afterPropertiesSet");
//		System.out.println("MyProperties: " + this);
		System.out.println("MyProperties: " + JSON.toJSONString(this));
		if (Boolean.TRUE.equals(bool)) {
			throw new RuntimeException("制造异常");
		}
	}

}
